From 8472201a6d86f95cbe751c10230e89ea4a07d764 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 23 Aug 2005 07:40:54 +0000 Subject: [PATCH] make formats only have one model --- babl/babl-classes.h | 24 +++++++++++++++++++++- babl/babl-fish.c | 49 ++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/babl/babl-classes.h b/babl/babl-classes.h index d834268..727be57 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -54,7 +54,9 @@ typedef void (*BablFuncPlanarBit) (int src_bands, typedef enum { BABL_INSTANCE = BABL_MAGIC, - BABL_TYPE, + BABL_TYPE, + BABL_TYPE_INTEGER, + BABL_TYPE_FLOAT, BABL_SAMPLING, BABL_COMPONENT, BABL_MODEL, @@ -77,6 +79,8 @@ typedef enum { #define BABL_CLASS_TYPE_IS_VALID(klass_type) \ ( ((klass_type)>=BABL_INSTANCE ) && ((klass_type)<=BABL_SKY) ?1:0 ) +const char *babl_class_name (BablClassType klass); + /* common header for any item inserted into database */ typedef struct { @@ -134,8 +138,26 @@ typedef struct BablConversion **to; /*< NULL terminated list of conversions to class */ int bits; /*< number of bits used to represent the data type (initially restricted to a multiple of 8) */ + double min_val; + double max_val; } BablType; +typedef struct +{ + BablType type; + int is_signed; + long max; + long min; +} BablTypeInteger; + +typedef struct +{ + BablType type; + /* sign + * biased_exponent + * mantissa */ +} BablTypeFloat; + typedef struct { BablInstance instance; diff --git a/babl/babl-fish.c b/babl/babl-fish.c index 3be6b33..678af6a 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -231,6 +231,9 @@ babl_fish_process (Babl *babl, Babl *imageB; Babl *imageC; + /* FIXME: assumptions made about memory requirements that + * are not good + */ fooA = babl_malloc(sizeof (double) * n * 4); fooB = babl_malloc(sizeof (double) * n * 4); @@ -247,12 +250,10 @@ babl_fish_process (Babl *babl, __FUNCTION__, babl_fish, source, destination, n); return -1; } - - babl->reference_fish.type_to_double->function.linear( - source, - fooA, - n* BABL(babl->fish.source)->pixel_format.bands - ); + + babl_conversion_process (babl->reference_fish.type_to_double, + source, fooA, + n * BABL(babl->fish.source)->pixel_format.bands); /* calculate planar representation of fooA, and fooB */ @@ -260,35 +261,29 @@ babl_fish_process (Babl *babl, imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA)); /* transform fooA into fooB fooB is rgba double */ - babl->reference_fish.model_to_rgba->function.planar( - imageA->image.bands, - imageA->image.data, - imageA->image.pitch, - imageB->image.bands, - imageB->image.data, - imageB->image.pitch, - n); + babl_conversion_process (babl->reference_fish.model_to_rgba, + imageA, imageB, + n); + babl_free (imageA); babl_free (imageB); /* calculate planar representation of fooC */ /* transform fooB into fooC fooC is ???? double */ - imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA)); - imageC = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.destination))->pixel_format.model)); - - babl->reference_fish.rgba_to_model->function.planar( - imageB->image.bands, - imageB->image.data, - imageB->image.pitch, - imageC->image.bands, - imageC->image.data, - imageC->image.pitch, - n); + imageB = babl_image_new_from_linear ( + fooB, babl_model_id (BABL_RGBA)); + imageC = babl_image_new_from_linear ( + fooA, BABL(BABL((babl->fish.destination))->pixel_format.model)); + babl_conversion_process (babl->reference_fish.rgba_to_model, + imageB, imageC, + n); - babl->reference_fish.double_to_type->function.linear( - fooA, destination, n * BABL(babl->fish.destination)->pixel_format.bands); + /* working directly on linear buffers */ + babl_conversion_process (babl->reference_fish.double_to_type, + fooA, destination, + n * BABL(babl->fish.destination)->pixel_format.bands); babl_free (imageB); babl_free (imageC); -- 2.30.2